#!/bin/bash

# Description : 
# Determine ORACLE_BASE AND ORACLE_HOME
#
#Get Oracle home from /etc/oratab
#Get Oracle base from ${ORACLE_HOME}/bin/oraenv
#
#This script should be run as oracle

ORACLE_SID=$1

if [ $ORACLE_SID ]; then
echo "ORACLE_SID is $ORACLE_SID"
export ORACLE_SID=$ORACLE_SID

ORACLE_HOME=`cat /etc/oratab | grep -i $ORACLE_SID | tr ":" " " | awk '{print $2}'`
echo "ORACLE_HOME is $ORACLE_HOME"
export ORACLE_HOME=$ORACLE_HOME

oraenv_path=$ORACLE_HOME/bin/oraenv
export export ORAENV_ASK=NO

ORACLE_BASE=`$oraenv_path | awk '{print $8}'`
echo "ORACLE_BASE is $ORACLE_BASE"
export ORACLE_BASE=$ORACLE_BASE

fi # test  if ORACLE_SID defined

